 var upload2; 
var privatecount=1;
var privatetalkstr="<div id='privatemessage'>"+ "发给：<input type='text' name='toName' id='toName' readonly='readonly'/><br/>"+
		          	"内容：<textarea rows='10' cols='20' name='messagContent' id='messagContent'></textarea><br/>"+ "</div>"+
				   "<div id='privatefiles'>"+"<div style='padding-left: 5px;'>"+ "<span id='spanButtonPlaceholder1'></span>"+
				   "<input id='btnCancel1' type='button' value='Cancel Uploads' onclick='cancelQueue(upload1)' disabled='disabled' style='margin-left: 2px; height: 22px; font-size: 8pt;' />"+
					 "<br />"+"</div>"+ "<div class='fieldset flash' id='fsUploadProgress1' style='float: center;'>"+ "<span class='legend'>文件上传</span>"+"</div>"+"</div>";

function sendswf2(){
	 upload2.startUpload();
}
function initSWFUpload2(){
	 upload2 = new SWFUpload({
			//提交路径
			upload_url: "PrivateTalkSWFUploadAction",
			//向后台传递额外的参数
			 post_params: {"toName" :$("#toName").val()},
			//上传文件的名称
			file_post_name: "file",
			
			// 下面自己按照字面意思理解
			file_size_limit : "102400",	// 100MB
			file_types : "*.txt;*.gif",
			file_types_description : "txt模式和JPG",
			file_upload_limit : "10",
			file_queue_limit : "0",

			// 事件处理
			file_dialog_start_handler : fileDialogStart,
			file_queued_handler : fileQueued,
			file_queue_error_handler : fileQueueError,
			file_dialog_complete_handler : fileDialogComplete,
			upload_start_handler : uploadStart,
			upload_progress_handler : uploadProgress,
			upload_error_handler : uploadError,
			upload_success_handler : uploadSuccess,
		    upload_complete_handler : uploadComplete,

			// 按钮的处理
			button_image_url : "swfupload/XPButtonUploadText_61x22.png",
			button_placeholder_id : "spanButtonPlaceholder1",
			button_width: 61,
			button_height: 22,
			
			// Flash Settings
			flash_url : "swfupload/swfupload.swf",
			custom_settings : {
				progressTarget : "fsUploadProgress1",
				cancelButtonId : "btnCancel1"
			},
			
			// Debug Settings
			debug: false
		});
	
}

function getTop(height){
	var windowheight=window.innerHeight;
	return (windowheight-height)/2;
}
function getLeft(width){
	var windowwidth=window.innerWidth;
	return (windowwidth-width)/2;
}

function openDialog2(customName){
			var content="";
			 $("#privatetalkdialog").dialog({
	        	  resizable:false,
	        	  show: "slide",
	        	  autoOpen:true,
	              module : true,
	              width:600,
	              height:450,
	              position:[getLeft(600),getTop(450)],//定位
	              title: "找他私聊下",
	              open:function(){
	            	  if(privatecount==1){
	            		 $("#privatetalkdialog").append(privatetalkstr).fadeIn();
	            		  privatecount=2;
	            	  }
	            	  $(toName).val(customName);
	            	  initSWFUpload2();
	              },
	              close: function(event, ui){
	            	  $("#messagContent").val("");
	              },
	              buttons:{
	            	  '提交' :function(){
	            		  content= $("#messagContent").val();
	            		  if(upload2.getStats().files_queued !== 0){
	            			  sendswf2();
	            		  }else if(upload2.getStats().files_queued === 0){
	            				alert("file is null");
	            			  $.post('SwfSuccessToDateBase',{'toName':$("#toName").val(),'filesName':"",'messageContent':$("#messagContent").val()},function(data){
	            					if(data=="true"){
	            						$("#message").html("您的私聊已经发到").dialog({
	            							autoOpen:true,
	            							width:300,
	            							height:180,
	            							position:[getLeft(300),getTop(180)],
	            							buttons:{
	            								确定:function(){
	            									$(this).dialog("close");
	            									$("#privatetalkdialog").dialog("close");
	            								}
	            							}
	            						});
	            						
	            					}else{
	            							alert("发送失败");
	            							$("#privatetalkdialog").dialog("close");
	            					}
	            				});
	            			
	            		  }
	            	  },
	            	  '取消':function(){
	            		  $(this).dialog('close');
	            	  }
	              },
	        });
			
		}